package com.bitland.demo.microservice1.controller;

import com.bitland.demo.microservice1.annotation.MyTestAnnotation;
import com.bitland.demo.microservice1.annotation.PermissionCheck;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping(value = "/demo")
public class DemoController {

    @Value("${server.port}")
    String port;

    @GetMapping("/hello/{name}")
    //测试地址 单服务测试地址  http://localhost:7001/ms1/demo/hello/zhangsan
    // 通过网关测试 http://localhost:7050/gateway/microService1/ms1/demo/hello/zhangsan
    public String importProducts(@PathVariable String name) {
        return "hello " + name + ", I am from port " + port;
    }

    @GetMapping({"/testAnnotation"})
    @PermissionCheck(permissionPoint = "insertDataPermission")
    @MyTestAnnotation("just test")
    //测试地址 单服务测试地址 http://localhost:7001/ms1/demo/testAnnotation
    public String testAnnotation() {
        log.info("------------------------> 2");
        return "success";
    }
}
